<?php
/**
 * ExtDataReaderBase class file
 *
 * @author TrueSoftware B.V. (The Netherlands)
 * @link http://www.ext4yii.com
 * @copyright Copyright 2007-2010 TrueSoftwareB.V. all rights reserved.
 * @license http://www.ext4yii.com/license/
 *          EVALUATION VERSION - NOT FOR COMMERCIAL USE OR DISTRIBUTION.
 * @version 0.7.2
 */
 
 
abstract class ExtDataReaderBase extends ExtWidget
{
    private $_readerfields_class_types = array('ExtReaderField');

    public function parseNode(ExtHTMLParserNode $node,
        ExtASTWalker $astwalker)
    {
        parent::parseNode($node, $astwalker);
        $this->parseReaderFields($node, $astwalker);
        $this->setReaderIdPropertyForCRUDController();
    }
    
    private function setReaderIdPropertyForCRUDController()
    {
        if($this->getController() instanceof ExtCRUDController)
        {
            $id = $this->parent->getId().'_reader_idproperty';
            Yii::app()->session[$id] = $this->getIdProperty();
        }                
    }

    private function parseReaderFields($node, $astwalker)
    {
        $fields = $node->findPropertyByName('readerfields');
        if(!is_null($fields))
        {
            $items=parent::parseNodeWidthTag($fields,
                $astwalker,
                true,
                array('asobject'=>false),
                $this,
                $this->_readerfields_class_types);
            $this->setArrayConfig('fields', $items);
            $fields->shiftUp();
        }
        $node->shiftUp();
    }

    //override
    protected function  configureClientIDs($registerID = true, $makeGlobal = true)
    {
        parent::configureClientIDs(false, false);
    }

    //override
    public function createContainer(ExtHTMLParserNode $node)
    {
        return null;
    }
}
?>
